  {% extends "base.html" %}
  {% block extrajs %}
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
  <script type="text/javascript" language="javascript">
    $(function() {
      $("input#id_q").autocomplete({
        minLength: 3,
        source: function(request, response) {
          var term = request.term;
	        $.getJSON("/search/autocomplete/", {'q': term}, function(data) {
	          var results = [];
	          $.each(data, function(k, v) {results.push(v.title);});
		        response(results);
	        });
        }
      });
    });
  </script>
  {% endblock %}

  {% block extracss %}
  <link rel="stylesheet" href="/static/style/snippets.css" type="text/css" />
  <link rel="stylesheet" href="/static/style/pygments.css" type="text/css" />
  <link rel="alternate" href="/feeds/latest/" type="application/atom+xml" title="Feed of latest snippets" />
  {% endblock %}

  {% block body%}
  {% block feeds %}{% endblock %}

  <div id="header">
    <h1><a href="/snippets/">QGIS Snippets</a></h1>
    <div id="nav-main">
      <span>
        {% if user.is_authenticated %}
          Logged in as <a href="/users/{{ user.username }}/">{{ user.username }}</a> (<a href="/snippets/add/">Add a snippet</a>) (<a href="/accounts/logout/">Log out</a>)
        {% else %}
          <a href="/accounts/login/?next={% ifequal request.path "/accounts/logout/" %}/{% else %}{{ request.path }}{% endifequal %}">Log in</a> or <a href="/accounts/register/">register</a>
        {% endif %}
      </span>
      <ul>
        <li id="nav-snippets"><a href="/snippets/">Snippets</a></li>
        {% if user.is_authenticated %}
          <li id="nav-account"><a href="/users/{{ user.username }}/">You</a></li>
        {% endif %}
        <li id="nav-about"><a href="/about/">About</a></li>
      </ul>
    </div>
  </div>

  <ul id="nav-secondary">
  {% block secondary_nav %}
    <li><a href="/users/">By author</a></li>
    <li><a href="/languages/">By language</a></li>
    <li><a href="/tags/">By tag</a></li>
    <li><a href="/popular/rated/">Highest-rated</a></li>
    <li><a href="/popular/bookmarked/">Most bookmarked</a></li>
  {% endblock %}
  </ul>


  <h2>{% block content_header %}{% endblock %}</h2>
  <div id="content">
    <div id="main">
      {% block content %}
      {% endblock %}
    </div>
    <div id="sidebar">
      <div style="padding: 15px;">
      </div>
    </div>
  </div>
  {% block extra_content %}
  {% endblock %}
{% endblock %}

{% block menu %}
{{ block.super }}
<div class="module_menu">
    <div class="cab">
        <div>
            <h3>Snippets</h3>
            <form method="get" action="/search/">
              <table>
                <tr>
                  <td><label for="id_q">Search:</label></td>
                  <td><input type="text" name="q" id="id_q" style="width: 110px;" value="{{ request.GET.q }}" /><input type="hidden" id="models" name="models" value="cab.snippet" /></td>
                  <td><input type="submit" value="Go" /></td>
                </tr>
              </table>
            </form>
          {% block sidebar %}
            {% load core_tags %}
            <p>Latest snippets:</p>
            <ul>
            {% for snippet in "cab.snippet"|latest:5 %}
              <li><a href="{{ snippet.get_absolute_url }}">{{ snippet.title }}</a> (<a href="{{ snippet.language.get_absolute_url }}">{{ snippet.language.name }}</a>) by <a href="/users/{{ snippet.author.username }}/">{{ snippet.author.username }}</a></li>
            {% endfor %}
            </ul>
          {% endblock %}
            <ul class="menu">
              <li><a href="/users/">By author</a></li>
              <li><a href="/languages/">By language</a></li>
              <li><a href="/tags/">By tag</a></li>
              <li><a href="/popular/rated/">Highest-rated</a></li>
              <li><a href="/popular/bookmarked/">Most bookmarked</a></li>
            </ul>
            {% if user.is_authenticated %}
            <h3>Your account</h3>
            <ul class="menu">
              <li><a href="/users/{{ user.username }}/">Your snippets</a></li>
              <li><a href="/snippets/add/">Add a snippet</a></li>
              <li><a href="/bookmarks/">Your bookmarks</a></li>
              <li><a href="/accounts/logout/">Log out</a></li>
            </ul>
            {% endif %}
            <h3>About</h3>
            <p>Powered by <a href="http://www.djangoproject.com/">Django</a>.</p>
            <p>Learn more <a href="/about/">about this site</a>.</p>
            <p>Read the <a href="/about/faq/">FAQ</a>.</p>
            <p><a href="/about/tos/">Terms of service</a></p>
            <p id="copyright">Backend code by <a href="http://www.b-list.org/">James Bennett</a> and <a href="http://charlesleifer.com">Charles Leifer</a>, design by <a href="http://www2.jeffcroft.com/">Jeff Croft</a>. Adapted for QGIS by Tim Sutton 2010.</p>
        </div>
    </div>
</div>
{% endblock %}

